Skip to content

Support col_wrap="auto"#11266

Merged
jsignell merged 8 commits intopydata:mainfrom
headtr1ck:auto-col
Apr 13, 2026
Merged

Support col_wrap="auto"#11266
jsignell merged 8 commits intopydata:mainfrom
headtr1ck:auto-col

Conversation

@headtr1ck
Copy link
Copy Markdown
Collaborator

@headtr1ck headtr1ck commented Mar 26, 2026

  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst

I often ended up writing this logic myself, better to make it as part of xarray.

While implementing it I noticed this comment:

idea - could add heuristic for nice shapes like 3x4

That should be covered now :)

@headtr1ck
Copy link
Copy Markdown
Collaborator Author

It would maybe be nice to not wrap 3 elements? But I guess that is debatable.

@headtr1ck
Copy link
Copy Markdown
Collaborator Author

v2 now takes into account the figsize if specified.
e.g. a figsize of (12, 6) and 8 images would result in a grid of 2x4.

@headtr1ck
Copy link
Copy Markdown
Collaborator Author

headtr1ck commented Mar 27, 2026

v3 now supports aspect as well.
Here some examples:

image image image image image image image image image image image

kkollsga added a commit to kkollsga/xarray that referenced this pull request Mar 29, 2026
Extend facetgrid_figsize to accept a (width, height) tuple in addition
to "computed" and "rcparams". Also move figsize resolution before grid
shape computation for better composition with col_wrap="auto" (pydata#11266).

Co-authored-by: Claude <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@Illviljan Illviljan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks very nice!

In V1 I had some thoughts of maybe calling the option "square" since it always strived towards that. But now it's clever enough for the generic "auto" I think.

Comment on lines -204 to -205
if row:
ncol = 1
Copy link
Copy Markdown
Contributor

@Illviljan Illviljan Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

row was not needed due to single_group=True. (either row or col is defined)

@headtr1ck headtr1ck added the plan to merge Final call for comments label Mar 29, 2026
@jsignell jsignell merged commit 452af83 into pydata:main Apr 13, 2026
43 checks passed
headtr1ck pushed a commit that referenced this pull request Apr 13, 2026
* Add facetgrid_figsize option to set_options (#11103)

Add a new `facetgrid_figsize` option to `xr.set_options()` that controls
how FacetGrid determines figure size when `figsize` is not explicitly
passed. When set to `"rcparams"`, FacetGrid uses
`matplotlib.rcParams['figure.figsize']` instead of computing size from
`size` and `aspect`. Default is `"computed"` (current behavior).

Co-authored-by: Claude <noreply@anthropic.com>

* Support tuple figsize in facetgrid_figsize option (#11103)

Extend facetgrid_figsize to accept a (width, height) tuple in addition
to "computed" and "rcparams". Also move figsize resolution before grid
shape computation for better composition with col_wrap="auto" (#11266).

Co-authored-by: Claude <noreply@anthropic.com>

* Update options.rst: broaden plotting section, add facetgrid_figsize

Co-authored-by: Claude <noreply@anthropic.com>

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Julia Signell <jsignell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

plan to merge Final call for comments topic-plotting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants